package com.video.system.service.impl;

import java.util.List;
import com.video.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.video.system.mapper.VideoCommodityMapper;
import com.video.system.domain.VideoCommodity;
import com.video.system.service.IVideoCommodityService;
import com.video.common.core.text.Convert;

/**
 * 商品Service业务层处理
 * 
 * @author lyh
 * @date 2021-07-21
 */
@Service
public class VideoCommodityServiceImpl implements IVideoCommodityService 
{
    @Autowired
    private VideoCommodityMapper videoCommodityMapper;

    /**
     * 查询商品
     * 
     * @param commodityId 商品ID
     * @return 商品
     */
    @Override
    public VideoCommodity selectVideoCommodityById(Integer commodityId)
    {
        return videoCommodityMapper.selectVideoCommodityById(commodityId);
    }

    /**
     * 查询商品列表
     * 
     * @param videoCommodity 商品
     * @return 商品
     */
    @Override
    public List<VideoCommodity> selectVideoCommodityList(VideoCommodity videoCommodity)
    {
        return videoCommodityMapper.selectVideoCommodityList(videoCommodity);
    }

    /**
     * 新增商品
     * 
     * @param videoCommodity 商品
     * @return 结果
     */
    @Override
    public int insertVideoCommodity(VideoCommodity videoCommodity)
    {
        videoCommodity.setCreateTime(DateUtils.getNowDate());
        return videoCommodityMapper.insertVideoCommodity(videoCommodity);
    }

    /**
     * 修改商品
     * 
     * @param videoCommodity 商品
     * @return 结果
     */
    @Override
    public int updateVideoCommodity(VideoCommodity videoCommodity)
    {
        videoCommodity.setUpdateTime(DateUtils.getNowDate());
        return videoCommodityMapper.updateVideoCommodity(videoCommodity);
    }

    /**
     * 删除商品对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteVideoCommodityByIds(String ids)
    {
        return videoCommodityMapper.deleteVideoCommodityByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除商品信息
     * 
     * @param commodityId 商品ID
     * @return 结果
     */
    @Override
    public int deleteVideoCommodityById(Integer commodityId)
    {
        return videoCommodityMapper.deleteVideoCommodityById(commodityId);
    }
}
